package com.quanshu.shop.person.view;

import android.content.Context;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.gyf.barlibrary.ImmersionBar;
import com.quanshu.change.person.view.HotGoodsActivity;
import com.quanshu.exchange.R;
import com.quanshu.exchange.support.utils.RxViewHelper;
import com.quanshu.exchange.ui.base.BaseActivity;
import com.quanshu.exchange.ui.base.MyApplication;
import com.quanshu.exchange.ui.gui.login.LoginActivity;
import com.quanshu.shop.base.tool.BaseTool;
import com.quanshu.shop.goods.view.CartActivity;
import com.quanshu.shop.limit.view.LimiteActivity;
import com.quanshu.shop.order.view.OrderListActivity;

import butterknife.BindView;
import butterknife.ButterKnife;

public class ShopPersonalActivity extends BaseActivity {
    @BindView(R.id.shop_person_main_title)
    LinearLayout linearLayoutTitle;
    @BindView(R.id.shop_person_main_order_go_img)
    ImageView shopPersonMainOrderGoImg;
    @BindView(R.id.shop_person_main_row1_img)
    ImageView shopPersonMainRow1Img;
    @BindView(R.id.shop_person_main_row1_txt)
    TextView shopPersonMainRow1Txt;
    @BindView(R.id.shop_person_main_row1_img1)
    ImageView shopPersonMainRow1Img1;
    @BindView(R.id.shop_person_main_row2_img)
    ImageView shopPersonMainRow2Img;
    @BindView(R.id.shop_person_main_row2_txt)
    TextView shopPersonMainRow2Txt;
    @BindView(R.id.shop_person_main_row2_img1)
    ImageView shopPersonMainRow2Img1;
    @BindView(R.id.shop_person_main_row3_img)
    ImageView shopPersonMainRow3Img;
    @BindView(R.id.shop_person_main_row3_txt)
    TextView shopPersonMainRow3Txt;
    @BindView(R.id.shop_person_main_row3_img1)
    ImageView shopPersonMainRow3Img1;
    @BindView(R.id.shop_person_go_cart)
    RelativeLayout shopPersonGoCart;
    @BindView(R.id.shop_person_go_like)
    RelativeLayout shopPersonGoLike;
    @BindView(R.id.shop_person_go_address)
    RelativeLayout shopPersonGoAddress;
    @BindView(R.id.shop_person_go_all_order)
    RelativeLayout shopPersonGoAllOrder;
    @BindView(R.id.shop_person_go_will_paid)
    TextView shopPersonGoWillPaid;
    @BindView(R.id.shop_person_go_will_transfer)
    TextView shopPersonGoWillTransfer;
    @BindView(R.id.shop_person_go_will_get)
    TextView shopPersonGoWillGet;
    @BindView(R.id.shop_person_go_finish)
    TextView shopPersonGoFinish;
    @BindView(R.id.shop_person_main_row5_img)
    ImageView shopPersonMainRow5Img;
    @BindView(R.id.shop_person_main_row5_txt)
    TextView shopPersonMainRow5Txt;
    @BindView(R.id.shop_person_main_row5_img1)
    ImageView shopPersonMainRow5Img1;
    @BindView(R.id.shop_person_go_hhtm)
    RelativeLayout shopPersonGoHhtm;
    @BindView(R.id.shop_person_test)
    RelativeLayout shopPersonTest;
    private Context mContext;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop_personal);
        ButterKnife.bind(this);
        mContext = this;
        init();
    }

    private void init() {
        ImmersionBar.with(this).titleBar(linearLayoutTitle).statusBarColor(R.color.color_eb2624).init();
        RxViewHelper.getInstance().clicks(linearLayoutTitle, aVoid ->
                finish());
        //购物车
        RxViewHelper.getInstance().clicks(shopPersonGoCart, aVoid ->
        {
            currentUser = MyApplication.getInstance().getCurrentUser();
            if (currentUser == null) {
                BaseTool.goActivity(mContext, LoginActivity.class, null);
                return;
            }
            BaseTool.goActivity(mContext, CartActivity.class, null);
        });

        RxViewHelper.getInstance().clicks(shopPersonGoLike, aVoid ->
                BaseTool.goActivity(this, MyLikeActivity.class, null));
        RxViewHelper.getInstance().clicks(shopPersonGoAddress, aVoid ->
                BaseTool.goActivity(this, MyAdressActivity.class, null));
        RxViewHelper.getInstance().clicks(shopPersonGoHhtm, aVoid ->
                BaseTool.goActivity(this, HotGoodsActivity.class, null));
        //全部订单
        RxViewHelper.getInstance().clicks(shopPersonGoAllOrder, aVoid -> {
            currentUser = MyApplication.getInstance().getCurrentUser();
            if (currentUser == null) {
                BaseTool.goActivity(mContext, LoginActivity.class, null);
                return;
            }
            Bundle bundle = new Bundle();
            bundle.putInt("ORDER_FLAG", 0);
            BaseTool.goActivity(this, OrderListActivity.class, bundle);

        });
        //待付款
        RxViewHelper.getInstance().clicks(shopPersonGoWillPaid, aVoid -> {
            currentUser = MyApplication.getInstance().getCurrentUser();
            if (currentUser == null) {
                BaseTool.goActivity(mContext, LoginActivity.class, null);
                return;
            }
            Bundle bundle = new Bundle();
            bundle.putInt("ORDER_FLAG", 1);
            BaseTool.goActivity(this, OrderListActivity.class, bundle);
        });

        //待发货
        RxViewHelper.getInstance().clicks(shopPersonGoWillTransfer, aVoid -> {
            currentUser = MyApplication.getInstance().getCurrentUser();
            if (currentUser == null) {
                BaseTool.goActivity(mContext, LoginActivity.class, null);
                return;
            }
            Bundle bundle = new Bundle();
            bundle.putInt("ORDER_FLAG", 2);
            BaseTool.goActivity(this, OrderListActivity.class, bundle);
        });

        //待收货
        RxViewHelper.getInstance().clicks(shopPersonGoWillGet, aVoid -> {
            currentUser = MyApplication.getInstance().getCurrentUser();
            if (currentUser == null) {
                BaseTool.goActivity(mContext, LoginActivity.class, null);
                return;
            }
            Bundle bundle = new Bundle();
            bundle.putInt("ORDER_FLAG", 3);
            BaseTool.goActivity(this, OrderListActivity.class, bundle);
        });

        //已完成
        RxViewHelper.getInstance().clicks(shopPersonGoFinish, aVoid -> {
            currentUser = MyApplication.getInstance().getCurrentUser();
            if (currentUser == null) {
                BaseTool.goActivity(mContext, LoginActivity.class, null);
                return;
            }
            Bundle bundle = new Bundle();
            bundle.putInt("ORDER_FLAG", 4);
            BaseTool.goActivity(this, OrderListActivity.class, bundle);
        });

        RxViewHelper.getInstance().clicks(shopPersonTest, aVoid ->
                BaseTool.goActivity(this, LimiteActivity.class, null));
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        ImmersionBar.with(this).destroy();
    }
}
